home *** CD-ROM | disk | FTP | other *** search
- Path: engnews1.Eng.Sun.COM!taumet!clamage
- From: clamage@Eng.sun.com (Steve Clamage)
- Newsgroups: comp.std.c++
- Subject: Re: virtual base class initialization
- Date: 21 Feb 1996 21:03:09 GMT
- Organization: Sun Microsystems Inc.
- Approved: clamage@eng.sun.com (comp.std.c++)
- Message-ID: <4gfs4g$ju2@engnews1.Eng.Sun.COM>
- References: <199602211555.IAA16749@ncar.ucar.EDU>
- Reply-To: clamage@Eng.sun.com
- NNTP-Posting-Host: taumet.eng.sun.com
- Content-Type: text
- X-Nntp-Posting-Host: taumet.eng.sun.com
- Content-Length: 902
- X-Lines: 27
- Originator: clamage@taumet
-
- In article IAA16749@ncar.ucar.EDU, weber@ezibk8.vmsmail.ethz.ch writes:
- >
- >// I am not sure how to interprate the ARM (or the Draft C++ Standard)
- >// with regard to the initialization of a virtual base class.
- >
- ... V is a virtual base class of A
-
- >class C2: public A, public B{
- >public:
- > C2(int i): A(i){}
- >};
- >
- >// C2 is not directly derived from V. In this case I don't think the base
- >// class should still be initialized by the most derived class.
-
- Yes it should. The most-derived class initializes all the virtual base
- classes in its hierarchy, whether the virtual base classes are direct
- base classes or not. None of the intermediate base classes initialize
- any of the virtual base classes.
-
- It would be possible to define other (probably more complicated) rules
- to specify a different order of initialization, but that is the C++ rule.
-
- ---
- Steve Clamage, stephen.clamage@eng.sun.com
-
-
-
- [ To submit articles: Try just posting with your newsreader.
- If that fails, use mailto:std-c++@ncar.ucar.edu
- FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
- Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu
- ]
-